// February 6, 1997
// Notes Application
application "paperroll" called "Notiz"

// Notes Soup
soup "Notes" called "Notiz" of "paperroll" range "optionalDateRange"

overview "notes:date" called "Datum" of "Notes" queries "timestamp" contains
        {
        column "Datum" width 115 is timestamp
        column "Datum Titel" width 200 is title
        }

class "paperroll" called "Notiz" of "Notes" contains
        {
        data: note called "Notiz" with options { "required" "automatic" }
        title: string called "Titel"
        timestamp: datetime called "Datum" default ""
        viewstationery := symbol "paperroll"
        height := value 200
        }
        
class "checkList" called "Check List" of "Notes" contains
        {
        timestamp: datetime called "Datum" default ""
        title: string called "Titel"
        topics: array called "Hauptgedanke" with options { "checklistnote" "required" } { entry called "Topic" contains
                        {
                        mtgdone: boolean called "Checked" default "O"
                        hideCount: integer called "Hide Count" default "0"
                        level: integer called "Level" default "1"
                        text: text called "Texte" with options { "automatic" }
                        viewbounds := bounds { 0 0 200 30 }
                        }
                }
        viewstationery := symbol "paperroll"
        height := value 200
        data := nil
        }
        
class "list" called "Outline" of "Notes" contains
        {
        timestamp: datetime called "Datum" default ""
        title: string called "Titel"
        topics: array called "Hauptgedanke" with options { "outlinenote" "required" } { entry called "Topic" contains
                        {
                        hideCount: integer called "Hide Count" default "0"
                        level: integer called "Level" default "1"
                        text: text called "Text" with options { "automatic" }
                        viewbounds := bounds { 0 0 200 30 }
                        }
                }
        viewstationery := symbol "paperroll"
        height := value 200
        data := nil
        }


// Names Application
application "cardfile" called "Kartei"

soup "Names" called "Kartei" of "cardfile" range "textRange"

overview "names:phones" called "Telefon Liste" of { "cardfile" "Names" } queries "sortOn" contains
        {
        column "Karten" width 150 is sortOn
        column "Telefon" width 117 is [ phones, 0 ]
        }
        
overview "names:email" called "E-Mail Liste" of { "cardfile" "Names" } queries "sortOn" contains
        {
        column "Karten" width 150 is sortOn
        column "E-Mail" width 117 is email
        }

overview "names:company" called "Firma Liste" of { "cardfile" "Names" } queries "sortOn" contains
        {
        column "Karten" width 150 is sortOn
        column "Firma" width 117 is company
        }
        
overview "names:bday" called "Geburtstag Liste" of { "cardfile" "Names" } queries "sortOn" contains
        {
        column "Karten" width 150 is sortOn
        column "Geburtstag" width 117 is bday
        }
        
class "Person" called "Personen" of { "cardfile" "Names" } contains
        {
        sortOn := format "%s %s" { name.last name.first }
        name: entry called "Name" with options { "required" } contains
                {
                honorific: string called "Anrede" with options { "automatic" }
                first: string called "Vorname" with options { "automatic" }
                last: string called "Nachname" with options { "automatic" }
                }
                
        addresses: set called "Adresse" firststoredin || { entry called "Adresse" contains
                        {
                        address: string called "Strasse"
                        address2: string called "Strasse2"
                        city: string called "Stadt"
                        region: string called "Bundesland"
                        postal_code: string called "PLZ"
                        country: string called "Land"
                        }
                }
        
        companies: set called "Firma" firststoredin || { entry called "Firma" contains
                        {
                        company: string called "Firma"
                        title: string called "Titel"
                        }
                }
                
        pagers: set called "Pager" { entry called "Pager" contains
                        {
                        pagerNum: string called "Pager" class "pagerClasses" with options { "titlefromclass" "firstclasswild" }
                        pagerPIN: string called "Pager PIN"
                        }
                }
                
        phones: set called "Telefon" { string called "Phone" class "phoneClasses" with options { "titlefromclass" "firstclasswild" } }
        emailAddrs: set called "E-Mail" firststoredin || { entry called "E-Mail" contains
                        {
                        email: string called "E-Mail" class "mailClasses" with options { "titlefromclass" "firstclasswild" }
                        }
                }
        bday: date called "Geburtstag"
        anniversary: date called "Jahrestag"
        notes: note called "Notiz"
        cardType: integer called "Card Type"
        }


class "company" called "Firma" of { "cardfile" "Names" } contains
        {
        sortOn := format "%s" { company }
        company: string called "Firma" with options { "required" }
        names: set called "Name" firststoredin name { entry called "Karten" contains
                        {
                        honorific: string called "Anrede"
                        first: string called "Vorname"
                        last: string called "Nachname"
                        title: string called "Titel"
                        }
                }
                
        addresses: set called "Adresse" firststoredin || { entry called "Adresse" contains
                        {
                        address: string called "Strasse"
                        address2: string called "Strasse2"
                        city: string called "Stadt"
                        region: string called "Bundesland"
                        postal_code: string called "PLZ"
                        country: string called "Land"
                        }
                }

        phones: set called "Telefon" { string called "Phone" class "phoneClasses" with options { "titlefromclass" "firstclasswild" } }
        emailAddrs: set called "E-Mail" firststoredin email { string called "EMail" class "mailClasses" with options { "titlefromclass" "firstclasswild" } }
        notes: note called "Notiz"
        cardType: integer called "Card Type"
        }


class "owner" called "Eigentumer" of { "cardfile" "Names" } with options { "nofolders" } contains
        {
        labels := symbol "_ownerNames"
        sortOn := format "%s %s" { name.last name.first }
        name: entry called "Notiz" with options { "required" } contains
                {
                honorific: string called "Anrede" with options { "automatic" }
                first: string called "Vorname" with options { "automatic" }
                last: string called "Nachname" with options { "automatic" }
                }
                
        addresses: set called "Adresse" firststoredin || { entry called "Adresse" contains
                        {
                        address: string called "Strasse"
                        address2: string called "Strasse2"
                        city: string called "Stadt"
                        region: string called "Bundesland"
                        postal_code: string called "PLZ"
                        country: string called "Land"
                        }
                }
        
        companies: set called "Firma" firststoredin || { entry called "Firma" contains
                        {
                        company: string called "Karten"
                        title: string called "Titel"
                        }
                }
                
        pagers: set called "Pager" firststoredin || { entry called "Pager" contains
                        {
                        pagerNum: string called "Pager" class "pagerClasses" with options { "titlefromclass" "firstclasswild" }
                        pagerPIN: string called "Pager PIN"
                        }
                }
                
        phones: set called "Telefon" { string called "Phone" class "phoneClasses" with options { "titlefromclass" "firstclasswild" } }
        emailAddrs: set called "E-Mail" firststoredin || { entry called "E-Mail" contains
                        {
                        email: string called "EMail" class "mailClasses" with options { "titlefromclass" "firstclasswild" }
                        emailpassword: string called "Password"
                        }
                }
        
        owner: entry called "Eigentumer Info" contains
                        {
                        bankAccounts: set called "Bankverbindung" { entry called "Bankverbindung" contains
                                        {
                                        bankAcctNum: string called "Konto"
                                        bankContactNum: string called "Telefon" class "phoneClasses" with options { "titlefromclass" "firstclasswild" }
                                        }
                                }
                                
                        creditCards: set called "Kreditkarte" { entry called "Kreditkarte" contains
                                        {
                                        creditCardNum: string called "Kartennummer"
                                        creditCardName: string called "Karten" class "creditClasses" with options { "titlefromclass" "firstclasswild" }
                                        creditCardExpDate: date called "Gultig bis"
                                        creditCardContactNum: string called "Tel.-Service"
                                        }
                        }
                }
                
        bday: date called "Geburtstag"
        anniversary: date called "Jahrestag"
        notes: note called "Notiz"
        cardType: integer called "Card Type"
        }

class "worksite" called "Arbeitsplatz" of { "cardfile" "Names" } with options { "nofolders" } contains
        {
        labels := symbol "_ownerNames"
        sortOn:= format "%s" { place }
        place: string called "Arbeitsplatz" with options { "required" }
        areaCode: string called "Vorwahl"
        dialingPrefix: string called "Dialing Prefix"
        notes: note called "Notiz"
        }
        
field class "creditClasses" |string.card| is "Card" ""
field class "creditClasses" |string.card.phonecard| is "Phone Card" ""
field class "creditClasses" |string.card.creditcard| is "Kreditkarte" ""
field class "creditClasses" |string.card.phonecard.att| is "AT&T" ""
field class "creditClasses" |string.card.phonecard.mci| is "MCI" ""
field class "creditClasses" |string.card.phonecard.sprint| is "Sprint" ""
field class "creditClasses" |string.card.creditcard.visa| is "VISA" ""
field class "creditClasses" |string.card.creditcard.mastercard| is "MasterCard" ""
field class "creditClasses" |string.card.creditcard.amex| is "AmEx" ""
field class "creditClasses" |string.card.creditcard.discover| is "Discover" ""

field class "pagerClasses" |string.pager| is "Pager" ""
field class "pagerClasses" |string.pager.skytel| is "SkyTel" ""
field class "pagerClasses" |string.pager.mobilecomm| is "MobileComm" ""
field class "pagerClasses" |string.pager.embarc| is "EMBARC" ""

field class "phoneClasses" otherPhone is "Telefon" ""
field class "phoneClasses" homePhone is "Privat" "H"
field class "phoneClasses" workPhone is "Bro" "W"
field class "phoneClasses" faxPhone is "Fax" "F"
field class "phoneClasses" carPhone is "Auto" "A"
field class "phoneClasses" mobilePhone is "Mobilfunk" "C"
field class "phoneClasses" homeFaxPhone is "Fax Privat" "HF"

field class "mailClasses" |string.email| is "Email" ""
field class "mailClasses" |string.email.internet| is "Internet" ""
field class "mailClasses" |string.email.aol| is "America Online" ""
field class "mailClasses" |string.email.compuserve| is "CompuServe" ""
field class "mailClasses" |string.email.mcimail| is "MCI Mail" ""
field class "mailClasses" |string.email.attmail| is "AT&T Mail" ""
field class "mailClasses" |string.email.easylink| is "EasyLink" ""
field class "mailClasses" |string.email.prodigy| is "Prodigy" ""
field class "mailClasses" |string.email.genie| is "GEnie" ""
field class "mailClasses" |string.email.delphi| is "Delphi" ""
field class "mailClasses" |string.email.msn| is "Network" ""
field class "mailClasses" |string.email.interchange| is "Interchange" ""
field class "mailClasses" |string.email.radiomail| is "RadioMail" ""


// Calendar Application
// Note that the calendar application is written using metasoups as the
// format is too complex and not really documented.
application "calendar" called "Kalender" with options { "nofolders" }

// Calendar Metasoup
metasoup "calendar:metasoup:REVELAR" called "Versammlung" of "calendar" range "dateRange"

overview "meetings:date" called "Termin" of "calendar:metasoup:REVELAR" queries "mtgStartDate" contains
        {
        column "Termin" width 120 is mtgStartDate
        column "Beschreibung" width 200 is mtgText
        }

class "meeting" called "Versammlung" of "calendar:metasoup:REVELAR" contains
        {
        mtgStartDate: datetime called "AnfangDatum" with options { "required" }
        mtgText: string called "Titel" with options { "required" }
        mtgDuration: integer called "Dauer" with options { "required" }
        notes: note called "Notiz"
        mtgAlarm: datetime called "Alarm"
        location: string called "Ort" with options { "readonly" }
        invitees: set called "Teilnehmer" with options { "readonly" }
                {
                string called "Invitee" with options { "readonly" }
                }
        }
        
class "repeatingMeeting" called "Wchentlicher Termin" of "calendar:metasoup:REVELAR" contains
        {
        mtgStartDate: datetime called "Terminanfang" with options { "required" }
        mtgText: string called "Titel" with options { "required" }
        mtgDuration: integer called "Dauer" with options { "required" }
        notes: note called "Notiz"
        mtgAlarm: datetime called "Alarm"
        location: string called "Ort" with options { "readonly" }
        invitees: set called "Teilnehmer" with options { "readonly" }
                {
                string called "Invitee" with options { "readonly" }
                }
        mtgStopDate: date called "Terminende"
        repeats: string called "Repeats" class "repeatClasses" with options { "suffixfromclass" "displayifempty" "required" }
        }
        
class "CribNote" called "Tagestermin" of "calendar:metasoup:REVELAR" contains
        {
        mtgStartDate: date called "Terminanfang" with options { "required" }
        mtgText: string called "Titel" with options { "required" }
        notes: note called "Notiz"
        }
        
class "repeatingCribNote" called "Mehrt
giger Termin" of "calendar:metasoup:REVELAR" contains
        {
        mtgStartDate: date called "Terminanfang" with options { "required" }
        mtgText: string called "Titel" with options { "required" }
        notes: note called "Notiz"
        mtgStopDate: date called "Terminende"
        repeats: string called "Weiderholen" class "repeatClasses" with options { "suffixfromclass" "displayifempty" "required" }
        }
        
field class "repeatClasses" |daily| is "Jeden Tag" "Jeden Tag"
field class "repeatClasses" |weekly| is "Jeden Woche" "Jeden Woche"
field class "repeatClasses" |biweekly| is "Jeden zweite Woche" "Jeden zweite Woche"
field class "repeatClasses" |monthly| is "Jeden Monat" "Jeden Monat"
field class "repeatClasses" |monthlyByWeek| is "Dieselbe Woche jeden Monat" "Dieselbe Woche jeden Monat"
field class "repeatClasses" |yearly| is "Jedes Jahr" "Jedes Jahr"
field class "repeatClasses" |yearlyByWeek| is "Dieselbe Woche jedes Jahr" "Dieselbe Woche jedes Jah"
field class "repeatClasses" |other| is "Anderer" ""


// To Do Application
application "todo" called "Aufgabenliste" with options { "nofolders" "readonly" }

// To Do Soup
soup "To Do List" called "Aufgabenliste" of "todo" range "dateRange"

overview "todo:date" called "Termin" of "To Do List" queries "date" contains
        {
        column "Termin" width 120 is date
        }

class "todo" called "Aufgabenliste Item" of "To Do List" with options { "readonly" } contains
        {
        |date|: date called "Datum"
        topics: set called "Items" { entry called "Aufgabenliste" contains
                        {
                        mtgdone: boolean called "Fertig"
                        mtgPriority: integer called "Prioritat"
                        text: text called "Texte"
                        }
                }
        }
        

range "dateRange" called "Heute" is "<range> [ daystart ... daystart + 1d )"
range "dateRange" called "Diese Woche" is "<range> [ weekstart ... weekstart + 1w )"
range "dateRange" called "Nachste Woche" is "<range> [ weekstart + 1w ... weekstart + 2w )"
range "dateRange" called "Diese Monate" is "<range> [ monthstart ... monthstart + 1m )"
range "dateRange" called "Nachste 30 Tage" is "<range> [ daystart ... daystart + 30d )"
range "dateRange" called "Nachste 60 Tage" is "<range> [ daystart ... daystart + 60d )"
range "dateRange" called "Nachste 90 Tage" is "<range> [ daystart ... daystart + 90d )"
range "dateRange" called "Nachste 120 Tage" is "<range> [ daystart ... daystart + 120d )"
range "dateRange" called "Nachste 180 Tage" is "<range> [ daystart ... daystart + 180d )"
range "dateRange" called "Nachste 365 Tage" is "<range> [ daystart ... daystart + 365d )"
range "dateRange" called "Vorige 30 Tage" is "<range> [ daystart - 30d ... daystart )"
range "dateRange" called "Vorige 60 Tage" is "<range> [ daystart - 60d ... daystart )"
range "dateRange" called "Vorige 90 Tage" is "<range> [ daystart - 90d ... daystart )"
range "dateRange" called "Vorige 120 Tage" is "<range> [ daystart - 120d ... daystart )"
range "dateRange" called "Vorige 180 Tage" is "<range> [ daystart - 180d ... daystart )"
range "dateRange" called "Vorige 365 Tage" is "<range> [ daystart - 365d ... daystart )"

range "optionalDateRange" called "Alle" is "<range> [ ... ]"
range "optionalDateRange" called "Heute" is "<range> [ daystart ... daystart + 1d )"
range "optionalDateRange" called "Diese Woche" is "<range> [ weekstart ... weekstart + 1w )"
range "optionalDateRange" called "Nachste Woche" is "<range> [ weekstart + 1w ... weekstart + 2w )"
range "optionalDateRange" called "Diese Monate" is "<range> [ monthstart ... monthstart + 1m )"
range "optionalDateRange" called "Nachste 30 Tage" is "<range> [ daystart ... daystart + 30d )"
range "optionalDateRange" called "Nachste 60 Tage" is "<range> [ daystart ... daystart + 60d )"
range "optionalDateRange" called "Nachste 90 Tage" is "<range> [ daystart ... daystart + 90d )"
range "optionalDateRange" called "Nachste 120 Tage" is "<range> [ daystart ... daystart + 120d )"
range "optionalDateRange" called "Nachste 180 Tage" is "<range> [ daystart ... daystart + 180d )"
range "optionalDateRange" called "Nachste 365 Tage" is "<range> [ daystart ... daystart + 365d )"
range "optionalDateRange" called "Vorige 30 Tage" is "<range> [ daystart - 30d ... daystart )"
range "optionalDateRange" called "Vorige 60 Tage" is "<range> [ daystart - 60d ... daystart )"
range "optionalDateRange" called "Vorige 90 Tage" is "<range> [ daystart - 90d ... daystart )"
range "optionalDateRange" called "Vorige 120 Tage" is "<range> [ daystart - 120d ... daystart )"
range "optionalDateRange" called "Vorige 180 Tage" is "<range> [ daystart - 180d ... daystart )"
range "optionalDateRange" called "Vorige 365 Tage" is "<range> [ daystart - 365d ... daystart )"

range "textRange" called "All" is "<range> [ ... ]"
range "textRange" called "#..D" is "<range> [ ... \"E\" )"
range "textRange" called "E..H" is "<range> [ \"E\" ... \"I\" )"
range "textRange" called "I..L" is "<range> [ \"I\" ... \"M\" )"
range "textRange" called "M..P" is "<range> [ \"M\" ... \"Q\" )"
range "textRange" called "Q..T" is "<range> [ \"Q\" ... \"U\" )"
range "textRange" called "U..X" is "<range> [ \"U\" ... \"Y\" )"
range "textRange" called "Y..Z" is "<range> [ \"Y\" ... ]"

// Calls Application
application "callapp" called "Anrufe" with options { "readonly" }

// Calls Soup
soup "Calls" called "Anrufe" of "callapp"

overview "calls:date" called "Datum" of "Calls" queries "timestamp"
contains
        {
        column "Datum" width 120 is timestamp
        column "Titel" width 150 is title
        }
        
class "calllog" called "Anrufe" of "Calls" contains
        {
        timestamp: datetime called "Datum"
        title: string called "Titel"
        name: string called "Kartei"
        phoneNumber: string called "Nummer"
        notes: note called "History"
       }